/*
 * Copyright (C), 2002-2017, 南京苏宁软件技术有限公司
 * FileName: RedPointTipsServiceImpl.java
 * Author:   10070706
 * Date:     2017年1月9日 下午2:33:37
 * Description: //模块目的、功能描述      
 * History: //修改记录
 * <author>      <time>      <version>    <desc>
 * 修改人姓名             修改时间            版本号                  描述
 */
package com.suning.sawp.service.impl.mainpushnew;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

import com.suning.sawp.constants.MainPushConstants;
import com.suning.sawp.intf.dao.mainpushnew.RedPointTipsDao;
import com.suning.sawp.intf.mainpushnew.RedPointTipsService;
import com.suning.sawp.po.mainpushnew.RedPointTips;
import com.suning.sawp.service.util.DateUtils;

/**
 * 功能简述: 小红点后台保存处理类<br>
 *
 * @author 10070706 陈辉
 */
@Service
public class RedPointTipsServiceImpl implements RedPointTipsService {

    @Autowired
    private RedPointTipsDao redPointTipsDao;

    @Override
    @Transactional
    public void saveRedPointTips(List<RedPointTips> redPointTips) {
        if (CollectionUtils.isEmpty(redPointTips)) {
            return;
        }
        redPointTipsDao.saveRedPointTips(redPointTips);
    }

    @Override
    public void createAllStoreRedPointTips(Long modelId) {
        RedPointTips tip = new RedPointTips();
        tip.setModelId(modelId);
        tip.setChangeType(MainPushConstants.TASK_CHANGE_TYPE);
        tip.setStoreCode(MainPushConstants.ALL_STORE);
        tip.setCreateTime(new Date());
        tip.setMonth(DateUtils.getThisMonth());

        List<RedPointTips> redPointTips = new ArrayList<RedPointTips>(1);
        redPointTips.add(tip);

        redPointTipsDao.saveRedPointTips(redPointTips);
    }
}
